<?php

declare (strict_types=1);

namespace app\api\controller;

use app\common\exception\BaseException;
use app\api\service\Home as HomeService;
use think\App;
use think\response\Json;

/**
 * 首页
 * Class User
 * @package app\api
 */
class Home extends Controller
{
    private $homeService;
    public function __construct(App $app,HomeService $homeService)
    {
        parent::__construct($app);
        
        $this->homeService = $homeService;
    }

    /**列表
     * @return Json
     */
    public function index(): Json
    {
        $params = $this->request->get();
        $this->validate(
            $params,
            [
                'page' => 'integer',
                'limit' => 'integer',
                'category_id' => 'integer',
            ]
        );
        $list = $this->homeService->getList($params);
        return $this->renderSuccess($list);
    }

    //分类
    public function categoryList():Json
    {
        $list = $this->homeService->getCategoryList();
        return $this->renderSuccess($list);
    }

    /**用户配置状态相关
     * @return Json
     */
    public function setOptions():Json
    {
        return $this->renderSuccess([]);
    }

}
